<template>
  <div class="header">
    <div class="titleName">
      <span @click="gohome">{{title}}</span>
      <template v-if="this.$store.getters.subTitle && this.$route.path!=='/'">
        <span class="subTitle">-{{this.$store.getters.subTitle}}</span>
      </template>
    </div>
  </div>
</template>
<script>

import { defaultTitle } from 'util/consts'

export default {
  name: 'Header',
  data () {
    return {
      title: defaultTitle
    }
  },
  methods: {
    // 跳转到首页
    gohome () {
      this.$router.push('/')
    }
  }
}
</script>

<style lang="less" scoped>
@import '~style/less_vars.less';

.header {
  background: @default-color;
  height: 50px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: #fff;
  font-size: 20px;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 99;
  .titleName {
    flex: 1;
    cursor: pointer;
    .subTitle {
      font-size: 16px;
    }
  }
  .admin {
    .iconfont {
      font-size: 20px;
    }
    .iconums-admin {
      padding-right: 10px;
      font-size: 22px;
      position: relative;
      top: 2px;
    }
  }
}
</style>
